package mapReduce.homework.q6_orderInfoTop10;

import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @Author:lixinlei
 * @Date:2021/4/21 7:01
 **/
public class GetMenuTop10Partitioner extends Partitioner<Text, NullWritable> {

    @Override
    public int getPartition(Text text, NullWritable nullWritable, int numPartitions) {

        int flag = 0;

        int year = Integer.parseInt(text.toString().split("\t")[0]);

        for (int i = 2000; i <= 2019 ; i++) {
            if (year == i){
                flag = i-2000;
                break;
            }
        }

        return flag;
    }
}
